package interfaz;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;


public class PanelInicial extends JPanel{

	private JButton b;
	public Ventana ventana;
	private PanelLogin login;
	private JLabel fondo;

	public PanelInicial(){

		login = new PanelLogin(this);
		ventana = new Ventana();
		ventana.pack();
		ventana.setLocationRelativeTo(null);
		ventana.setVisible( true );
		ventana.getContentPane().add( this, "Center" );
		ventana.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		fondo = new JLabel();

		setVisible(true);

		setLayout(null);

		try {
			UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}

		//Boton prueba
		b = new JButton();
		b.setText("Siguiente");
		b.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent evt) {
				login(evt);
			}

			public void mouseEntered(MouseEvent arg0) {

			}

			public void mouseExited(MouseEvent arg0) {

			}

			public void mousePressed(MouseEvent arg0) {	   }

			public void mouseReleased(MouseEvent arg0) {	}
		});
		this.add(b);
		b.setBounds(50,50, 120, 40);

		fondo.setIcon(new ImageIcon("src/resources/.png"));
		add(fondo);
		fondo.setBounds(0, 0, 800, 600);

	}

	private void login(MouseEvent evt) {
		this.setVisible(false);
		ventana.getContentPane().add(login, 0);
		login.setVisible(true);
	}

	public static void main(String[] args) {
		new PanelInicial();
	}

}
